package com.spring.sunflower.login

import com.spring.sunflower.base.BaseObserver
import com.spring.sunflower.base.BasePresenter
import com.spring.sunflower.bean.*

/**
 * Created by Kevin on 2021/9/18<br/>
 *
 * Describe:<br/>
 */
class DoorPresenter(baseView: LoginContract.DoorView) :
    BasePresenter<LoginContract.DoorView>(baseView) {
    fun getExchangeID() {
        val observable = requestDataSource.requestBalance("4")
        addDisposable(observable, object : BaseObserver<BalanceBean>(baseView) {
            override fun onSuccess(bean: BalanceBean) {
                baseView.showExchangeList(bean.datas)
            }

            override fun onError(status: Int, msg: String?) {
            }
        });

    }
    fun getWeChatH5PayResult(orderNo:String) {
        val observable = requestDataSource.getWeChatH5PayResult(orderNo)
        addDisposable(observable, object : BaseObserver<WeChatH5PayResultBean>(baseView) {
            override fun onSuccess(bean: WeChatH5PayResultBean) {
                baseView.showWeChatH5PayResult(bean.datas)

            }

            override fun onError(status: Int, msg: String?) {
            }
        })

    }
    fun getWeChatH5Pay(map:MutableMap<String,String>) {
        val observable = requestDataSource.getWeChatH5Pay(map)
        addDisposable(observable, object : BaseObserver<WeChatH5Bean>(baseView) {
            override fun onSuccess(bean: WeChatH5Bean) {
                baseView.showWeChatH5Data(bean.datas)

            }

            override fun onError(status: Int, msg: String?) {
            }
        });

    }
    fun getWeChatH5PayProduct(map: MutableMap<String, String>) {
        val observable = requestDataSource.getWeChatH5PayProduct(map)
        addDisposable(observable, object : BaseObserver<WeChatH5Bean>(baseView) {
            override fun onSuccess(bean: WeChatH5Bean) {
                baseView.showWeChatH5Data(bean.datas)

            }

            override fun onError(status: Int, msg: String?) {
            }
        });

    }
    fun aliPayGenerate(exchangeId: String) {
        val observable = requestDataSource.aliPayGenerate(exchangeId)
        addDisposable(observable, object : BaseObserver<CommonBean>(baseView) {
            override fun onSuccess(bean: CommonBean) {
                baseView.showAliGenerateData(bean.datas)
            }

            override fun onError(status: Int, msg: String?) {
            }
        });

    }

    fun aliPayGenerateVip(vipInfoId: String) {
        val observable = requestDataSource.aliPayGenerateVip(vipInfoId)
        addDisposable(observable, object : BaseObserver<CommonBean>(baseView) {
            override fun onSuccess(bean: CommonBean) {
                baseView.showAliGenerateVipData(bean.datas)
            }

            override fun onError(status: Int, msg: String?) {
            }
        });

    }

    fun aliPayH5(exchangeId: String, userIdOrMobile: String) {
        val observable = requestDataSource.aliPayH5(exchangeId, userIdOrMobile)
        addDisposable(observable, object : BaseObserver<CommonBean>(baseView) {
            override fun onSuccess(bean: CommonBean) {
                baseView.showAliGenerateH5Data(bean.datas)
            }

            override fun onError(status: Int, msg: String?) {
            }
        });

    }

    fun weChatPayGenerate(exchangeId: String) {
        val observable = requestDataSource.weChatPayGenerate(exchangeId)
        addDisposable(observable, object : BaseObserver<WeChatPayBean>(baseView) {
            override fun onSuccess(bean: WeChatPayBean) {
                baseView.showWeChatGenerateData(bean.datas)
            }

            override fun onError(status: Int, msg: String?) {
            }
        });

    }

    fun weChatPayGenerateVip(vipInfoId: String) {
        val observable = requestDataSource.weChatPayGenerateVip(vipInfoId)
        addDisposable(observable, object : BaseObserver<WeChatPayBean>(baseView) {
            override fun onSuccess(bean: WeChatPayBean) {
                baseView.showWeChatGenerateVipData(bean.datas)
            }

            override fun onError(status: Int, msg: String?) {
            }
        });

    }

    fun weChatPayH5(exchangeId: String, userIdOrMobile: String) {
        val observable = requestDataSource.weChatPayH5(exchangeId, userIdOrMobile)
        addDisposable(observable, object : BaseObserver<WeChatPayBean>(baseView) {
            override fun onSuccess(bean: WeChatPayBean) {
                baseView.showWeChatGenerateH5Data(bean.datas)
            }

            override fun onError(status: Int, msg: String?) {
            }
        })

    }
}